﻿package com.sng.stg.game.Player 
{
	import com.sng.stg.game.event.ContinuousEvent;
	import com.sng.stg.game.event.GameOver;
	import com.sng.stg.game.event.PlayerHit;
	import com.sng.stg.game.StageViewer;
	import flash.display.Sprite;
	
	/**
	 * ...
	 * @author snega
	 */
	public class Player extends Sprite
	{
		public var _life:int = 1;
		
		public var _stage:StageViewer = null;
		
		public var _notInvincible:Boolean = true;
		
		public var _point:int = 0;
		public var _graze:int = 0;
		
		public function Player(stage:StageViewer) 
		{			
			this._stage = stage;
		}
		
		public function hit():void {
			if (this._notInvincible) {
				if (-- this._life == 0) {
					var e:ContinuousEvent = new GameOver();
					e.start(this._stage);
					this._stage._continuousEventList.push(e);
					this._notInvincible = false;
					this._stage._playerEnable = false;
					this.alpha = 0;
				}
				else {
					trace(this._life + " lives left.");
					var playerHit:PlayerHit = new PlayerHit(this._stage);
					this._notInvincible = false;
				}
			}
		}
		
	}
	
}